/*
 * PAT_1003.cpp
 *
 *  Created on: 2013-3-5
 *      Author: zxt
 */
//find all the paths between start and end

#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#define MAX_LENGTH 99999	//max arc length

using namespace std;

int firstAdjVex(int v, int n, int **arc){
	int i;
	for(i=0; i<n; i++){
		if(arc[v][i] < MAX_LENGTH)
			return i;
	}
	return -1;		//considering this is a connected graph, so "-1" will not happen
}

int nextAdjVex(int v, int cur, int n, int **arc){
	int i;
	for(i=cur+1; i<n; i++){
		if(arc[v][i] < MAX_LENGTH)
			return i;
	}
	return -1;
}

void findVex(int **arc, const int n, int i, const int end, vector<int> curStep, vector<vector<int> > &path){
//	printf("i: %d\n", i);
	curStep.push_back(i);
	if(i == end){
		//add to path
		path.push_back(curStep);
		//pop last vex
		curStep.pop_back();
		return;
	}
	int j = firstAdjVex(i, n, arc);
	for(; j>=0; j=nextAdjVex(i, j, n, arc)){
		if(find(curStep.begin(), curStep.end(), j) == curStep.end())
			findVex(arc, n, j, end, curStep, path);
	}
}

int main(){
	if(freopen("PAT_1003.txt","r",stdin) == NULL){
		printf("Open data file failed! Please check again.");
		return 0;
	}

	int n, m, start, end;
	while(scanf("%d%d%d%d", &n, &m, &start, &end) > 0){
		//init
		vector<int> vTeamNum;
		int **arc = new int* [n];
		int i, j;
		for(i=0; i<n; i++){
			arc[i] = new int[n];
			for(j=0; j<n; j++)
				arc[i][j] = MAX_LENGTH;
		}
		//input number of rescue teams in the i-th city
		for(i=0; i<n; i++){
			int teamNum;
			scanf("%d", &teamNum);
			vTeamNum.push_back(teamNum);
		}
		//input arcs(undirected graph)
		int a, b, l;
		while(m--){
			scanf("%d%d%d", &a, &b, &l);
			arc[a][b] = l;
			arc[b][a] = l;
		}

		//TODO
		vector<int> curStep;
		vector<vector<int> > path;
		findVex(arc, n, start, end, curStep, path);

		//print result
//		for(i=0; i<path.size(); i++){
//			for(j=0; j<path[i].size(); j++){
//				printf("%d ", path[i][j]);
//			}
//			printf("\n");
//		}

        //find the shortest length and the max rescue team num
        int shortestLength = MAX_LENGTH, pathCount = 0;
        int maxTeamNum = 0;
        for(i=0; i<path.size(); i++){
            int length = 0;
            int teamNum = vTeamNum[path[i][0]];
            for (j=1; j<path[i].size(); j++) {
                length += arc[path[i][j-1]][path[i][j]];
                teamNum += vTeamNum[path[i][j]];
            }
            if(shortestLength > length){
                pathCount = 1;
                shortestLength = length;
                maxTeamNum = teamNum;
            }
            else if(shortestLength == length){
                pathCount++;
                if(maxTeamNum < teamNum)
                    maxTeamNum = teamNum;
            }
        }
        printf("%d %d\n", pathCount, maxTeamNum);
	}//big while

	return 0;
}
